<?php

namespace common\models\base;

use Yii;

/**
 * This is the model class for table "{{%custom}}".
 *
 * @property int $id
 * @property int $guarantee_company_id
 * @property int $guarantee_company_user_id
 * @property string $master_name 客户名称
 * @property string $orderno 分配的合作机构业务订单编号
 * @property string $mobile
 * @property string $address
 * @property string $unit
 *
 * @property CarOrder[] $carOrders
 * @property CarOrder $carOrder
 * @property CreditOrder[] $creditOrders
 * @property DividedPaymentsOrder $dividedPaymentsOrder
 * @property FileListInfo[] $fileListInfos
 * @property ManualPics[] $manualPics
 * @property SpecialCard $specialCard
 */
class Custom extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%custom}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['guarantee_company_id', 'guarantee_company_user_id', 'master_name', 'orderno'], 'required'],
            [['guarantee_company_id', 'guarantee_company_user_id'], 'integer'],
            [['master_name', 'orderno', 'mobile', 'address', 'unit'], 'string', 'max' => 100],
            [['guarantee_company_id', 'guarantee_company_user_id'], 'unique', 'targetAttribute' => ['guarantee_company_id', 'guarantee_company_user_id']],
            [['orderno'], 'unique'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'guarantee_company_id' => Yii::t('app', 'Guarantee Company ID'),
            'guarantee_company_user_id' => Yii::t('app', 'Guarantee Company User ID'),
            'master_name' => Yii::t('app', '客户名称'),
            'orderno' => Yii::t('app', '分配的合作机构业务订单编号'),
            'mobile' => Yii::t('app', 'Mobile'),
            'address' => Yii::t('app', 'Address'),
            'unit' => Yii::t('app', 'Unit'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getCarOrders()
    {
        return $this->hasMany(CarOrder::className(), ['custom_id' => 'id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getCreditOrders()
    {
        return $this->hasMany(CreditOrder::className(), ['custom_id' => 'id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getCreditOrder()
    {
        return $this->hasOne(CreditOrder::className(), ['custom_id' => 'id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getDividedPaymentsOrder()
    {
        return $this->hasOne(DividedPaymentsOrder::className(), ['custom_id' => 'id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getFileListInfos()
    {
        return $this->hasMany(FileListInfo::className(), ['custom_id' => 'id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getManualPics()
    {
        return $this->hasMany(ManualPics::className(), ['custom_id' => 'id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getSpecialCard()
    {
        return $this->hasOne(SpecialCard::className(), ['custom_id' => 'id']);
    }
}
